{\rtf1\ansi\ansicpg936\cocoartf1187\cocoasubrtf340
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue192;}
\paperw11900\paperh16840\margl1440\margr1440\vieww19820\viewh10120\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural

\f0\fs24 \cf0 DB::query("UPDATE ".DB::table('talk_category')." SET talk_num = talk_num + 1 WHERE `cat_id`='\{$post['sub_cat']\}'");\
\
////////////////////////\
$count = DB::result_first("SELECT COUNT(*)\
								   FROM ".DB::table('talk_category')."\
								   WHERE cat_name='\{$cat_name\}' AND parent_id='\{$pid\}'");\
\
\
////////////////////////\
function id2category($cat_id)\
\{\
	$category = array();\
	$category = DB::fetch_first("SELECT * FROM ".DB::table('talk_category')." WHERE cat_id='\{$cat_id\}'");\
	return $category;\
\}\
\
$category = $this->id2category($cat_id);\
if (empty($category)) \{\
	return -1;\
\}\
\
if ($category['talk_num'] > 0) \{\
	return -2;\
\}\
\
\
////////////////////////\
DB::query("DELETE FROM ".DB::table('talk_category')." WHERE cat_id='\{$cat_id\}'");\
\
\
////////////////////////\
$cat_ary = array();\
$query = DB::query("SELECT * FROM ".DB::table('talk_category')." ORDER BY display_order ASC");\
while ($value = DB::fetch($query))\
 \{\
	if ($value['parent_id'] == 0) \
        \{\
		$cat_ary['first'][$value['cat_id']] = $value;\
	\}\
        else \
        \{\
	         $cat_ary['second'][$value['cat_id']] = $value;\
	\}\
\}\
\
\
if (!empty($cat_ary['first'])) \
\{\
	foreach ($cat_ary['first'] as $key => $v)\
        \{\
		$tmp_cat_id = $v['cat_id'];\
		$count = DB::result_first("SELECT COUNT(*) FROM ".DB::table('talk_category')." WHERE parent_id='\{$tmp_cat_id\}'");\
		if ($count < 1) \{\
			unset($cat_ary['first'][$key]);\
		\}\
	\}\
	ConfigHandler::set('talk_category', $cat_ary);\
	return $cat_ary;\
\}\
\
\
////////////////////////\
$count = DB::result_first("SELECT COUNT(*) FROM ".DB::table('talk')." WHERE lid='\{$lid\}'");\
\
////////////////////////\
$ret = DB::query("update ".DB::table('members')." set `level`='$role_level' where `uid`='$uid'");\
\
////////////////////////\
$query = DB::query("SELECT * FROM ".DB::table('channel')." ORDER BY parent_id DESC");\
while ($value = DB::fetch($query)) \
\{\
	$totala = DB::result_first("SELECT COUNT(*) FROM ".DB::table('topic')." WHERE item = 'channel' AND item_id = '\{$value['ch_id']\}'");\
	DB::query("UPDATE ".DB::table('channel')." SET total_topic_num=\{$totala\},topic_num=\{$totala\} WHERE ch_id='\{$value['ch_id']\}'");\
	if($value['parent_id'] == 0)\
        \{\
		$total = DB::result_first("SELECT SUM(topic_num) FROM ".DB::table('channel')." WHERE parent_id = '\{$value['ch_id']\}'");\
		if($total > 0)\{\
			DB::query("UPDATE ".DB::table('channel')." SET total_topic_num=total_topic_num+\{$total\} WHERE ch_id='\{$value['ch_id']\}'");\
		\}\
	\}\
\}\
\
\
/////////////////////////////\
$set_ary = array(\
	'ch_name' => $ch_name,\
	'parent_id' => $parent_id,\
	'display_order' => $display_order,\
);\
$cid = DB::insert('channel', $set_ary, true);\
\
\
/////////////////////////////\
$setarr = array(\
			'livename' => $post['livename'],\
			'description' => $post['description'],\
			'image' => $post['image'],\
			'starttime' => strtotime($post['starttime']),\
			'endtime' => strtotime($post['endtime']),\
		);\
\
$return = DB::update('live', $setarr, array('lid' => jget('lid','int','P')));\
if($return && !empty($_FILES['image']['name']))\
\{\
	$this->upload_pic(jget('lid','int','P'));\
\}\
\
\
/////////////////////////////\
$sql_limit = '';\
if($p['per_page_num'])\
\{\
	$page = page($count, $p['per_page_num'], $p['page_url'], array('return' => 'Array'));\
\
	$sql_limit = " \{$page['limit']\} ";\
\}\
elseif($p['limit'])\
\{\
	if(false !== strpos(strtolower($p['limit']), 'limit '))\
	\{\
		$sql_limit = " \{$p['limit']\} ";\
	\}\
	else\
	\{\
		$sql_limit = " limit \{$p['limit']\} ";\
	\}\
\}\
\
$sql_order = '';\
if($p['order'])\
\{\
	if(false !== strpos(strtolower($p['order']), 'order by '))\
	\{\
		$sql_order = " \{$p['order']\} ";\
	\}\
	else\
	\{\
		$sql_order = " order by \{$p['order']\} ";\
	\}\
\}\
\
$sql_fields = ($p['fields'] ? $p['fields'] : "*");\
\
$query = DB::query("select $sql_fields from ".DB::table($this->table)." $sql_where $sql_order $sql_limit ");\
while(false != ($r = DB::fetch($query)))\
\{\
	$r['type'] = 'images/filetype/'.$r['filetype'].'.gif';\
	$r['time'] = my_date_format($r['dateline']);\
	$r['size'] = ($r['filesize'] > 1024*1024) ? round($r['filesize']/(1024*1024),2).'MB' : round($r['filesize']/1024,1).'KB';\
	$list[] = $r;\
\}\
\
\
$query = DB::query("SELECT iid,itemid,uid,description,type FROM ".DB::table('item_user')." WHERE item = 'live' AND itemid IN(".jimplode($ids).")");\
while($row = DB::fetch($query)) \
\{\
	$uids[] = $row['uid'];\
	$guests[$row['itemid']][$row['uid']]['type'] = $row['type'];\
	$guests[$row['itemid']][$row['uid']]['iid'] = $row['iid'];\
	$guests[$row['itemid']][$row['uid']]['description'] = $row['description'];\
\}\
\
\
$query = DB::query("SELECT * FROM ".DB::table('live')." WHERE starttime <= '$time' ORDER BY `endtime` DESC LIMIT ".$live_num);\
while($row = DB::fetch($query)) \
\{\
	$out_script_live[] = $row;\
\}\
\
\
\
\
\
\pard\pardeftab720

\f1\fs22 \cf0 $_sql = \cf2 "SELECT DISTINCT * \cf0 \
\pard\pardeftab720
\cf2 					FROM \cf0 \
\cf2 						"\cf0 .DB::table(\cf2 'bd_friends'\cf0 ).\cf2 " AS t1 \cf0 \
\cf2 					JOIN \cf0 \
\cf2 						(SELECT ROUND(RAND()*((SELECT MAX(index) FROM "\cf0 .DB::table(\cf2 'bd_friends'\cf0 ).\cf2 ") -(SELECT MIN(index) FROM 									"\cf0 .DB::table(\cf2 'bd_friends'\cf0 ).\cf2 ")) + (SELECT MIN(index) FROM "\cf0 .DB::table(\cf2 'bd_friends'\cf0 ).\cf2 ") AS id) AS t2 \cf0 \
\cf2 					WHERE \cf0 \
\cf2 						t1.index >=t2.id \cf0 \
\cf2 					ORDER BY \cf0 \
\cf2 						t1.index \cf0 \
\cf2 					LIMIT 10"\cf0 ;\
			\
			\
$_sql =\cf2 "SELECT \cf0 \
\cf2 						* \cf0 \
\cf2 					FROM \cf0 \
\cf2 						"\cf0 .DB::table(\cf2 'player'\cf0 ).\cf2 " A\cf0 \
\cf2 					WHERE \cf0 \
\cf2 						NOT EXISTS(\cf0 \
\cf2 								SELECT \cf0 \
\cf2 									* \cf0 \
\cf2 								FROM \cf0 \
\cf2 									"\cf0 .DB::table(\cf2 'bd_friends'\cf0 ).\cf2 " B\cf0 \
\cf2 								WHERE \cf0 \
\cf2 									A.player_account =B.player_account AND\cf0 \
\cf2 									A.player_token =B.player_token AND \cf0 \
\cf2 									B.friend_account ='\cf0 \{$this->\cf2 playerAccount\cf0 \}\cf2 ' AND\cf0 \
\cf2 									B.friend_token ='\cf0 \{$this->\cf2 playerToken\cf0 \}\cf2 ')"\cf0 ;\

\f0\fs24 \
}